package common

import (
	"github.com/go-redis/redis/v8"
	"gorm.io/gorm"
	"log"
)

var (
	LocalSetting  *Setting
	ConsulSetting *Setting
	DB            *gorm.DB
	Red           *redis.Client
)

func init() {
	var err error
	LocalSetting, err = NewLocalSetting()
	if err != nil {
		log.Println("LocalSetting err:", err)
	}
	ConsulSetting, err = NewConsulSetting(LocalSetting.vp.GetString("consulSetting.url"), LocalSetting.vp.GetString("consulSetting.fileKey"))
	if err != nil {
		log.Println("ConsulSetting err:", err)
	}
	Red, err = GetRedisFromConsul()
	if err != nil {
		log.Println("GetRedisFromConsul err:", err)
	}
	DB, err = GetMySQLFromConsul()
	if err != nil {
		log.Println("GetMySQLFromConsul err:", err)
	}
}
